
#include "MyXMLErrorReporter.h"
#include <xercesc/sax/SAXParseException.hpp>
#include <iostream>
#include <cstdlib>
#include <cstring>

void MyXMLErrorReporter::warning(const SAXParseException&)
{
    //
    // Ignore all warnings.
    //
}

void MyXMLErrorReporter::error(const SAXParseException& toCatch)
{
    char num[100];
    memset(num, 0, sizeof(num));
    fSawErrors = true;
    errStr += "Error at file [";
    errStr += L(toCatch.getSystemId());
    errStr += "], line ";
    sprintf(num, "%ld", (long int) toCatch.getLineNumber());
    errStr += num;
    errStr += ", column ";
    memset(num, 0, sizeof(num));
    sprintf(num, "%ld", (long int) toCatch.getColumnNumber());
    errStr += num;
    errStr += ", Message: ";
    errStr += L(toCatch.getMessage());
}

void MyXMLErrorReporter::fatalError(const SAXParseException& toCatch)
{
    char num[100];
    memset(num, 0, sizeof(num));
    fSawErrors = true;
    errStr += "Fatal Error at file [";
    errStr += L(toCatch.getSystemId());
    errStr += "], line ";
    sprintf(num, "%ld", (long int) toCatch.getLineNumber());
    errStr += num;
    errStr += ", column ";
    memset(num, 0, sizeof(num));
    sprintf(num, "%ld", (long int) toCatch.getColumnNumber());
    errStr += num;
    errStr += ", Message: ";
    errStr += L(toCatch.getMessage());
}

void MyXMLErrorReporter::resetErrors()
{
    fSawErrors = false;
    errStr = "";
}

bool MyXMLErrorReporter::getSawErrors() const
{
    return fSawErrors;
}
